﻿@{
    ViewBag.Title = "备料输入";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}

<script>
    var rowData = {};
    var index = -1;
    $(function () {
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/VBaseData/V_CPK_31_BL_StoArcPreMaterial/GetStockpreparationRegList",
            height: $(window).height() - 120,
            colModel: [
            { label: '主键', name: 'FPreMaterialID', width: 100, align: 'center', hidden: true },
            { label: '<input id="selectAll" type="checkbox" style="text-align:center;">', width: 60, align: 'center', sortable: false, formatter: $.checkbox, unformat: $.empty },
            { label: '领料单位', name: 'FHappenComNO', width: 100, align: 'center' },
            { label: '领料单位名称', name: 'FHappenComName', width: 80, align: 'center' },
            { label: '出库日期', name: 'FCurDate', width: 100, align: 'center' },
            { label: '零件编号', name: 'FProductionNO', width: 80, align: 'center' },
            { label: '零件名称', name: 'FProductionName', width: 80, align: 'center' },
            { label: '开票数量', name: 'FQuantity_KP', width: 80, align: 'center' },

            { label: '实际数量', name: 'FQuantity', width: 80, align: 'center' },
            { label: '库存数量', name: 'FQuantity', width: 80, align: 'center' },
            { label: '仓库编号', name: 'FStoreNO', width: 80, align: 'center' },
            { label: '库位编号', name: 'FStoreSetNO', width: 80, align: 'center' },

            { label: '容器编号', name: 'FContainerNO', width: 80, align: 'center' },
            { label: '容器名称', name: 'FContainerName', width: 80, align: 'center' },
            { label: '容器数量', name: 'FContainerQuantity', width: 80, align: 'center' },
            { label: '实际装箱', name: 'FContent', width: 80, align: 'center' },
            { label: '标准装箱', name: 'FFactContent', width: 80, align: 'center' },

            { label: '托盘编号', name: 'FPalletNO', width: 80, align: 'center' },
            { label: '托盘数量', name: 'FPalletQuantity', width: 80, align: 'center' },
            { label: '实际容量', name: 'FPalletContent', width: 80, align: 'center' },
            { label: '标准容量', name: 'FPalletFactContent', width: 80, align: 'center' },
            { label: '凭证编号', name: 'FVoucherNo', width: 80, align: 'center' },
            { label: '备注', name: 'Fdescription', width: 80, align: 'center' },
            { label: '供货单位', name: 'FSupplierNO', width: 80, align: 'center' },

            { label: '供货单位名称', name: 'FSupplierName', width: 120, align: 'center' },
            { label: '送检单号', name: 'FCheckBillCode', width: 120, align: 'center' },
            { label: '零件分类', name: 'FProductionTypeNO', width: 80, align: 'center' },
            { label: '输入人员', name: 'FCreateBy', width: 80, align: 'center' },
            { label: '输入日期', name: 'FCreateDate', width: 80, align: 'center' },
            { label: '输入时间', name: 'FCreateTime', width: 80, align: 'center' }
            ],
            sortname: 'F_DepartmentId asc,F_CreatorTime desc',
            viewrecords: true,
            onSelectRow: function (rowId) {
                rowData = $gridList.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
        $("#selectAll").click(function (e) {
            $("input[name='checkbox']").prop("checked", this.checked);
            e.stopPropagation();
        });
    }

    function btn_Save() {
        var postData = [];
        $("#gridList input:checkbox:checked").each(function () {
            var rowid = $(this).attr("value");
            postData.push($("#gridList").jqGrid('getRowData', rowid));
        });
        $.submitForm({
            url: "/WareHouse/EnterWareHouse/SavePrepareToOut",
            param: { datas: JSON.stringify(postData) },
            success: function () {
                $("#gridList").resetSelection();
                $("#gridList").trigger("reloadGrid");
            }
        })
    }

    function btn_Edit() {
        debugger
        $.each(rowData, function (key, value) {
            rowData[key] = $("#txt" + key).val();
        });
        $("#gridList").jqGrid('setRowData', index, rowData);
    }
    function btn_Return() {
        parent.$.detailClose();
    }
</script>

<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-center">
        <form id="form1">
            <table class="form" style="width:97%;text-align:left;margin:0px;margin-top:-20px;margin-bottom:-3px; border-bottom:2px solid #ccc;">
                <tr>
                    <td style="width:97%; padding:5px 10px;">
                        <div class="btn-group" style="margin-left:500px;margin-bottom:-10px;">
                            <h2 style="font-family:隶书;font-weight:bold;font-size:26px">备料输入</h2>
                        </div>
                        <div class="btn-group" style="margin-left:470px;margin-bottom:-25px;">
                            <a id="" class="btn btn-primary center-block " onclick="btn_Save()"><span class="glyphicon glyphicon-ok"></span> 保存</a>
                        </div>
                        <div class="btn-group" style="margin-left:30px;margin-bottom:-25px;">
                            <a id="" class="btn btn-primary center-block  " onclick="btn_Return()"><span class="glyphicon glyphicon-remove"></span> 返回</a>
                        </div>
                    </td>
                </tr>
            </table>

            <div style="width:600px;margin:5px auto 2px auto;">
                <table id="eidt_entity" class="form">
                    <tr>
                        <th class="formTitle">零件编号</th>
                        <td class="formValue" style="width:140px;">
                            <input id="txtFProductionNO" name="FProductionNO" class="form-control" type="text">
                        </td>

                        <th class="formTitle">实际数量</th>
                        <td class="formValue" style="width:60px;">
                            <input id="txtFQuantity" name="FQuantity" class="form-control decimal" type="text">
                        </td>

                        <th class="formTitle"></th>
                        <td class="formValue" style="width:60px;">
                        </td>
                    </tr>

                    <tr>
                        <th class="formTitle">零件名称</th>
                        <td class="formValue">
                            <input id="txtFProductionName" name="FProductionName" class="form-control" type="text">
                        </td>

                        <th class="formTitle">容器数量</th>
                        <td class="formValue">
                            <input id="txtFContainerQuantity" name="FContainerQuantity" class="form-control decimal" type="text">
                        </td>
                        <td class="formValue" style="width:60px;margin:0 auto;">
                            <a class="btn btn-primary center-block" style="padding:2px;" onclick="btn_Edit()">修改</a>
                        </td>

                    </tr>
                </table>
            </div>
        </form>
        <div style="">
            <table id="gridList"></table>
        </div>
    </div>
</div>



